package com.ygxsk.carhome.ui.adapter;

import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.ygxsk.carhome.R;
import com.ygxsk.carhome.response.MessageListItemBean;
import com.ygxsk.carhome.utils.CommUtils;

import java.util.List;

/*
 * @Author:itchenqi175@163.com
 * @Time:2023-08-06  13:50
 * @Description：添加列表适配
 */
public class MessageListItemAdapter extends BaseQuickAdapter<MessageListItemBean, BaseViewHolder> {

    public MessageListItemAdapter(int layoutResId, @Nullable List<MessageListItemBean> data) {
        super(layoutResId, data);

        //设置点击事件；
        addChildClickViewIds(R.id.textviewlookdetail);

    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, MessageListItemBean messageListItemBean) {

        if (messageListItemBean != null) {

            //设置item数据；
            //获取名字
            String messageType = messageListItemBean.getTitle();
            String messageContent = messageListItemBean.getContent();
            String messageTime = messageListItemBean.getCreateTime();

            //findViews

            //标签的类型
            TextView textViewMesageTypeTag = (TextView) baseViewHolder.getView(R.id.textviewmesagetypetag);
            //完整的标题
            TextView textViewMesageTitleFull = (TextView) baseViewHolder.getView(R.id.textviewmesagetitlefull);
            //查看详情的按钮
            //TextView textViewLookDetail = (TextView) baseViewHolder.getView(R.id.textviewlookdetail);
            //发送消息的时间
            TextView textViewTimePublish = (TextView) baseViewHolder.getView(R.id.textviewtimepublish);


            //名称
            CommUtils.setText(textViewMesageTypeTag, messageType);
            //完整的标题
            CommUtils.setText(textViewMesageTitleFull, messageContent);
            //消息发布的时间
            CommUtils.setText(textViewTimePublish, messageTime);

        }

    }

}
